/**
 * Created by zhangshibin on 2016/12/3.
 */
//import Vue from 'vue'
import FormObject from './components/FormObject.vue'

var globalObj=new Vue({
    el: '#form_info',
    template:'<FormObject :inputDefine="inputDefine" :formData="formData" :isRoot="true" @dataChange="dataChange"></FormObject>',
    components:{
        "FormObject":FormObject
    },
    data(){
        return{
            inputDefine:{
                key:"vue_root_el",name:"vue_root_el",displayName:"root节点", elementType:"formObject",defValue:{},
                inputDefines:[
                    {key:"key1",name:"key1",displayName:"第一个key", elementType:"input",defValue:"2121"},
                    {key:"key2",name:"key2",displayName:"第2个key", elementType:"textarea",defValue:"gfgfrg"},
                    {key:"key3",name:"key3",displayName:"第3个key", elementType:"radio",defValue:""},
                    {key:"subForm",name:"subForm",displayName:"一个form", elementType:"formObject",defValue:{},
                        inputDefines:[
                            {key:"key_sub1",name:"key_sub1",displayName:"子key1", elementType:"input",defValue:"键盘"},
                            {key:"key_sub2",name:"key_sub2",displayName:"子key2", elementType:"input",defValue:"鼠标"}
                        ]
                    }
                ]
            },
            formData:{}
        }
    },
    methods:{
        "dataChange":function (dataInfo) {
            this.formData=dataInfo['newValue'];
            console.log("root change");
            console.log(this.formData);
        }
    }
})

window['globalObj']=globalObj;